package com.wat4m.jerome.jdpcpool.util;

import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;

import com.mchange.v2.c3p0.ComboPooledDataSource;

public class C3P0Util {
	private static Connection conn=null;
    private static ComboPooledDataSource comboPooledDataSource=new ComboPooledDataSource();
    
    static{
        try {
			comboPooledDataSource.setDriverClass("org.mariadb.jdbc.Driver");
			comboPooledDataSource.setJdbcUrl("jdbc:mysql://localhost:3306/store");
			comboPooledDataSource.setUser("root");
			comboPooledDataSource.setPassword("123456");
		} catch (PropertyVetoException e) {
			e.printStackTrace();
		}
    }
    public static Connection getConnection(){
    	try {
			conn=comboPooledDataSource.getConnection();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        return conn;
    }
    public static void main(String[] args) throws SQLException{
    	Connection con=C3P0Util.getConnection();
    	con.close();
    }
}
